<%@ page language="java" contentType="text/html;charset=UTF-8" %>
<%@ page import="com.gouwudai.gobbs.pojo.TbbsUserInfo"%>
<%@ include file="../../common/common.jsp" %>
<%@ include file="master_pass.jsp" %>
<% 
Integer userId = Utility.parseInt(request.getParameter("userId"));

IUserService userService = (IUserService)BeanManager.getBean("userService");
TbbsUserInfo obj = userService.load(userId);	
%>
<HTML>
<HEAD>
<title>编辑用户信息</title>
<%@ include file="../../common/meta.inc" %>
<link href="css.css" rel="stylesheet" type="text/css">
<SCRIPT LANGUAGE="javascript" SRC="${pageContext.request.contextPath}/scripts/common-validator.js"></SCRIPT>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/prototype.js"></script>
<script language="javascript" src="${pageContext.request.contextPath}/scripts/buffalo/buffalo.js"></script>
<script language="javascript">
var END_POINT="${pageContext.request.contextPath}/buffalo";
var buffalo = new Buffalo(END_POINT);
function doSubmit() {

	form = document.theform;
	
	if(!validateForm(form))
		return;
		
    var obj = {};
	obj.userId=<%=userId%>;
	obj.userMoney=$F('userMoney');
	
	obj.userDeposit=$F('userDeposit');
	obj.userMark=$F('userMark');
	obj.userCredit=$F('userCredit');
	obj.upfileOpenFlag=sl_parseBoolean($F('upfileOpenFlag'));	
	obj.upfileSize = parseInt($F('upfileSize'));		
	obj.gradeId=parseInt($F('gradeId'));
		
    buffalo.remoteCall("userServiceAjaxService.updateAdmin",[obj], function(reply) {
        ajaxSubmit(reply.getResult(),"保存成功！","back");
    });
}

function validateForm(form)
{
    if(!sl_checkDecimal(form.userMoney,"用户金币",8,2,0)) return false;
    if(!sl_checkDecimal(form.userDeposit,"帐户存款",8,2,0)) return false;
    if(!sl_checkDecimal(form.userMark,"用户积分",8,2,0)) return false;
    if(!sl_checkDecimal(form.userCredit,"用户信誉",8,2,0)) return false;    
    if(!sl_checkIntValue(form.upfileSize,"个人上传空间容量",10000,0)) return false;
    if(!sl_checkChoice(form.gradeId,"用户等级")) return false;   
    
    return sl_confirmUpdate();
}
</script>
</HEAD>
<BODY>
<script language="javascript">
  setTitle("用户管理","编辑用户信息");
</script>
<form name="theform" method="post">
<table class="bluetable" width="100%">	
	<tr>
         <th colspan="2" align="right">编辑用户信息</th>
    </tr>
	<tr>
		<td class="title" align="right" width="20%">用户名:</td>
		<td><input type="text" name="loginId" id="loginId" value="<%=obj.getLoginId() %>" class="edline" readonly onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>	
	<tr>
		<td class="title" align="right">用户昵称:</td>
		<td><input type="text" name="masterName" id="masterName" value="<%=obj.getUserName() %>"  class="edline" readonly onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>							
	<tr>
		<td class="title" align="right">用户金币:</td>
		<td><input type="text" name="userMoney" id="userMoney" value="<%=obj.getUserMoney() %>"  onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>
	<tr>
		<td class="title" align="right">帐户存款:</td>
		<td><input type="text" name="userDeposit" id="userDeposit" value="<%=obj.getUserDeposit() %>"  onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>
	<tr>
		<td class="title" align="right">用户积分:</td>
		<td><input type="text" name="userMark" id="userMark" value="<%=obj.getUserMark() %>"  onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>
	<tr>
		<td class="title" align="right">用户信誉:</td>
		<td><input type="text" name="userCredit" id="userCredit" value="<%=obj.getUserCredit()%>"  onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>
	<tr>
		<td class="title" align="right">是否允许用户上传:</td>
		<td>
		<select size="1" name="upfileOpenFlag" id="upfileOpenFlag" onkeydown="javascript:nextKeyPress(this)">
			<%=Arguments.booleanOptions(obj.getUpfileOpenFlag().booleanValue())%>
		</select>
		</td>
	</tr>
	<tr>
		<td class="title" align="right">个人上传空间容量:</td>
		<td><input type="text" name="upfileSize" id="upfileSize" value="<%=obj.getUpfileSize() %>"  onkeydown="javascript:nextKeyPress(this)" size="20"></td>
	</tr>		
	<tr>
		<td class="title" align="right">用户等级:</td>
		<td>
		<select size="1" name="gradeId" id="gradeId" onkeydown="javascript:nextKeyPress(this)">
			<%=Arguments.getUserGradeOptions(obj.getGradeId())%>
		</select>
		</td>
	</tr>																																			
</table>
<table class="btntable" width="100%">
	<tr>
		<td>
		<button class="btn" accessKey=s id="btnSave" name="btnSave" onclick="javascript:doSubmit();">保存(<u>S</u>)</button>
		&nbsp;&nbsp;
		<button class="btn" accessKey=c id="btnCancel" name="btnCancel" onclick="javascript:history.back();">取消(<u>C</u>)</button>
		&nbsp;&nbsp;								
		</td>
	</tr>
</table>
</form>
</BODY>
</HTML>

